package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormEventDetailImproveDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.FlowFormEventDetailImprove;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormEventDetailImproveConverter {

    public static FlowFormEventDetailImproveDto do2Dto(FlowFormEventDetailImprove domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        return FlowFormEventDetailImproveMapper.INSTANCE.do2Dto(domain);
    }

    public static List<FlowFormEventDetailImproveDto> do2Dto(List<FlowFormEventDetailImprove> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormEventDetailImproveConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormEventDetailImprove dto2Do(FlowFormEventDetailImproveDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        return FlowFormEventDetailImproveMapper.INSTANCE.dto2Do(dto);
    }

    public static List<FlowFormEventDetailImprove> dto2Do(List<FlowFormEventDetailImproveDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormEventDetailImproveConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormEventDetailImproveMapper {

        FlowFormEventDetailImproveMapper INSTANCE = Mappers.getMapper(FlowFormEventDetailImproveMapper.class);

        FlowFormEventDetailImproveDto do2Dto(FlowFormEventDetailImprove domain);

        List<FlowFormEventDetailImproveDto> do2Dto(List<FlowFormEventDetailImprove> domain);

        FlowFormEventDetailImprove dto2Do(FlowFormEventDetailImproveDto dto);

        List<FlowFormEventDetailImprove> dto2Do(List<FlowFormEventDetailImproveDto> dto);
    }
}
